package com.mfp.java.testYou.db.model;

import java.util.LinkedList;
import java.util.List;

import com.mfp.java.testYou.core.utils.FormatUtils;

public class Test extends Entity {

	private static final long serialVersionUID = 4105811407152739298L;

	private String title;
	private List<Question> questions;
	private boolean finalTest, allowHints;
	
	public final String getTitle() {
		return title;
	}

	public final void setTitle(String title) {
		this.title = title;
	}

	public final List<Question> getQuestions() {
		if (questions == null) {
			questions = new LinkedList<Question>();
		}
		return questions;
	}

	public final void setQuestions(List<Question> questions) {
		this.questions = questions;
	}

	public final boolean isFinalTest() {
		return finalTest;
	}

	public final void setFinalTest(boolean finalTest) {
		this.finalTest = finalTest;
	}

	public final boolean isAllowHints() {
		return allowHints;
	}

	public final void setAllowHints(boolean allowHints) {
		this.allowHints = allowHints;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append(title);
		sb.append(" - ");
		if (finalTest) {
			sb.append('F');
			sb.append(" - ");
		}
		if (allowHints) {
			sb.append('H');
			sb.append(" - ");
		}

		sb.append("[");

		for (Question q : getQuestions()) {
			sb.append(FormatUtils.removeTags(q.getText(), 10));
			sb.append(",");
		}

		sb.append("]");
		return sb.toString();
	}

}
